Quản lý website giới thiệu và bán điện thoại di động ASP.net
19.323 lượt xem;
- admin.master.cs
- project /
1 using System;
2 using System.Data;
3 using System.Configuration;
4 using System.Collections;
5 using System.Web;
6 using System.Web.Security;
7 using System.Web.UI;
8 using System.Web.UI.WebControls;
9 using System.Web.UI.WebControls.WebParts;
10 using System.Web.UI.HtmlControls;
11 using System.Data.OleDb;
12
13 public partial class MasterPage : System.Web.UI.MasterPage
14 {
15 TimKiemData tk;
16
17 protected void Page_Load(object sender, EventArgs e)
18 {
19 ado.ketNoi();
20 lblslkhach.Text = Application.Contents["sltruycap"].ToString();
21 lbltructuyen.Text = Application.Contents["sltructuyen"].ToString();
22
23
24 OleDbDataAdapter da1 = new OleDbDataAdapter("Select * From timkiem", ado.con);
25 DataTable dt1 = new DataTable();
26 da1.Fill(dt1); MenuItem tmp1;
27 foreach (DataRow dr1 in dt1.Rows)
28 {
29 tmp1 = new MenuItem(dr1[2].ToString(), dr1[0].ToString(), "~/Images/blue_arrow.gif");
30 tmp1.NavigateUrl = "timkiem.aspx?gia=" + dr1[0].ToString()+"&"+"gia2=" + dr1[1].ToString();
31 tmp1.SeparatorImageUrl = "~/Images/nganmenu.gif";
32 Menu5.Items.Add(tmp1);
33
34 }
35 OleDbDataAdapter da2 = new OleDbDataAdapter("Select * From phongcach", ado.con);
36 DataTable dt2 = new DataTable();
37 da2.Fill(dt2); MenuItem tmp2;
38 foreach (DataRow dr2 in dt2.Rows)
39 {
40 tmp2 = new MenuItem(dr2[1].ToString(), dr2[0].ToString(), "~/Images/blue_arrow.gif");
41 tmp2.NavigateUrl = "phongcach.aspx?id=" + dr2[0].ToString();
42 tmp2.SeparatorImageUrl = "~/Images/nganmenu.gif";
43 Menu6.Items.Add(tmp2);
44
45 }
46 OleDbDataAdapter da3 = new OleDbDataAdapter("Select * From kieudang", ado.con);
47 DataTable dt3 = new DataTable();
48 da3.Fill(dt3); MenuItem tmp3;
49 foreach (DataRow dr3 in dt3.Rows)
50 {
51 tmp3 = new MenuItem(dr3[1].ToString(), dr3[0].ToString(), "~/Images/blue_arrow.gif");
52 tmp3.NavigateUrl = "kieudang.aspx?id=" + dr3[0].ToString();
53 tmp3.SeparatorImageUrl = "~/Images/nganmenu.gif";
54 Menu7.Items.Add(tmp3);
55
56 }
57
58
59 }
60
61
62 protected void RememberMe_CheckedChanged(object sender, EventArgs e)
63 {
64
65 }
66 protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
67 {
68
69 }
70 protected void btndangnhap_Click(object sender, EventArgs e)
71 {
72 ado.ketNoi();
73 string query = "select * from tbluser where email='" + txtemail.Text + "' and matkhau='" + txtpass.Text + "'";
74 ado.rd = ado.getData(query);
75 if (ado.rd.Read())
76 {
77 FormsAuthentication.SetAuthCookie(txtemail.Text, true);
78 Session["email"] = txtemail.Text;
79 Session["matkhau"] = ado.rd[1].ToString();
80 Session["quyen"] = ado.rd[2].ToString();
81 Session["hoten"] = ado.rd[3].ToString();
82 Session["diachi"] = ado.rd[4].ToString();
83 Session["dienthoai"] = ado.rd[5].ToString();
84 Session["soCMND"] = ado.rd[6].ToString();
85 Session["mataikhoan"] = ado.rd[7].ToString();
86
87 if (Session["quyen"].ToString() == "admin")
88 Response.Redirect("themqtri.aspx");
89 else
90 Response.Redirect("thongtintaikhoan.aspx", true);
91 }
92 else
93 {
94 txtemail.Focus();
95 }
96
97 ado.rd.Dispose();
98 ado.dongKetNoi();
99 }
100 protected void Button1_Click(object sender, EventArgs e)
101 {
102
103 }
104 protected void Button1_Click1(object sender, EventArgs e)
105 {
106
107 }
108 protected void timKiem(object sender, CommandEventArgs e)
109 {
110 {
111 try
112 {
113 Session["TuKhoa"] = TextBox3.Text;
114 Session["KQTimKiem"] = null;
115 tk = new TimKiemData();
116 DataTable tb;
117 tb = tk.setTable();
118 //string TinhTrang = "";
119 ado.ketNoi();
120 string query = "";
121 if (TextBox3.Text != "")
122 {
123 query = "Select Anh, TenSP,Gia,soluong,'chitiet.aspx?tensp='+tensp as chitiet from tblSanPham where TenSP like '" + TextBox3.Text + "%'";
124 }
125 ado.rd = ado.getData(query);
126 while (ado.rd.Read())
127 {
128 tb = tk.dienVaoBang(tb, ado.rd["Anh"].ToString(), ado.rd["TenSP"].ToString(), Convert.ToDouble(ado.rd["Gia"]), Convert.ToDouble(ado.rd["soluong"]), ado.rd["chitiet"].ToString());
129 //if ((bool)ado.rd.GetValue(3) == true)
130 // TinhTrang = "Còn Hàng";
131 //else
132 // TinhTrang = "Hết Hàng";
133
134 }
135 ado.dongKetNoi();
136 Session["KQTimKiem"] = tb;
137 Response.Redirect("timten.aspx", true);
138 }
139 catch (Exception ex)
140 {
141 Response.Write(ex.ToString());
142 }
143 }
144 }
145 protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
146 {
147
148 }
149 protected void Menu1_MenuItemClick1(object sender, MenuEventArgs e)
150 {
151
152 }
153 protected void DataList1_SelectedIndexChanged(object sender, EventArgs e)
154 {
155
156 }
157 }
2 using System.Data;
3 using System.Configuration;
4 using System.Collections;
5 using System.Web;
6 using System.Web.Security;
7 using System.Web.UI;
8 using System.Web.UI.WebControls;
9 using System.Web.UI.WebControls.WebParts;
10 using System.Web.UI.HtmlControls;
11 using System.Data.OleDb;
12
13 public partial class MasterPage : System.Web.UI.MasterPage
14 {
15 TimKiemData tk;
16
17 protected void Page_Load(object sender, EventArgs e)
18 {
19 ado.ketNoi();
20 lblslkhach.Text = Application.Contents["sltruycap"].ToString();
21 lbltructuyen.Text = Application.Contents["sltructuyen"].ToString();
22
23
24 OleDbDataAdapter da1 = new OleDbDataAdapter("Select * From timkiem", ado.con);
25 DataTable dt1 = new DataTable();
26 da1.Fill(dt1); MenuItem tmp1;
27 foreach (DataRow dr1 in dt1.Rows)
28 {
29 tmp1 = new MenuItem(dr1[2].ToString(), dr1[0].ToString(), "~/Images/blue_arrow.gif");
30 tmp1.NavigateUrl = "timkiem.aspx?gia=" + dr1[0].ToString()+"&"+"gia2=" + dr1[1].ToString();
31 tmp1.SeparatorImageUrl = "~/Images/nganmenu.gif";
32 Menu5.Items.Add(tmp1);
33
34 }
35 OleDbDataAdapter da2 = new OleDbDataAdapter("Select * From phongcach", ado.con);
36 DataTable dt2 = new DataTable();
37 da2.Fill(dt2); MenuItem tmp2;
38 foreach (DataRow dr2 in dt2.Rows)
39 {
40 tmp2 = new MenuItem(dr2[1].ToString(), dr2[0].ToString(), "~/Images/blue_arrow.gif");
41 tmp2.NavigateUrl = "phongcach.aspx?id=" + dr2[0].ToString();
42 tmp2.SeparatorImageUrl = "~/Images/nganmenu.gif";
43 Menu6.Items.Add(tmp2);
44
45 }
46 OleDbDataAdapter da3 = new OleDbDataAdapter("Select * From kieudang", ado.con);
47 DataTable dt3 = new DataTable();
48 da3.Fill(dt3); MenuItem tmp3;
49 foreach (DataRow dr3 in dt3.Rows)
50 {
51 tmp3 = new MenuItem(dr3[1].ToString(), dr3[0].ToString(), "~/Images/blue_arrow.gif");
52 tmp3.NavigateUrl = "kieudang.aspx?id=" + dr3[0].ToString();
53 tmp3.SeparatorImageUrl = "~/Images/nganmenu.gif";
54 Menu7.Items.Add(tmp3);
55
56 }
57
58
59 }
60
61
62 protected void RememberMe_CheckedChanged(object sender, EventArgs e)
63 {
64
65 }
66 protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
67 {
68
69 }
70 protected void btndangnhap_Click(object sender, EventArgs e)
71 {
72 ado.ketNoi();
73 string query = "select * from tbluser where email='" + txtemail.Text + "' and matkhau='" + txtpass.Text + "'";
74 ado.rd = ado.getData(query);
75 if (ado.rd.Read())
76 {
77 FormsAuthentication.SetAuthCookie(txtemail.Text, true);
78 Session["email"] = txtemail.Text;
79 Session["matkhau"] = ado.rd[1].ToString();
80 Session["quyen"] = ado.rd[2].ToString();
81 Session["hoten"] = ado.rd[3].ToString();
82 Session["diachi"] = ado.rd[4].ToString();
83 Session["dienthoai"] = ado.rd[5].ToString();
84 Session["soCMND"] = ado.rd[6].ToString();
85 Session["mataikhoan"] = ado.rd[7].ToString();
86
87 if (Session["quyen"].ToString() == "admin")
88 Response.Redirect("themqtri.aspx");
89 else
90 Response.Redirect("thongtintaikhoan.aspx", true);
91 }
92 else
93 {
94 txtemail.Focus();
95 }
96
97 ado.rd.Dispose();
98 ado.dongKetNoi();
99 }
100 protected void Button1_Click(object sender, EventArgs e)
101 {
102
103 }
104 protected void Button1_Click1(object sender, EventArgs e)
105 {
106
107 }
108 protected void timKiem(object sender, CommandEventArgs e)
109 {
110 {
111 try
112 {
113 Session["TuKhoa"] = TextBox3.Text;
114 Session["KQTimKiem"] = null;
115 tk = new TimKiemData();
116 DataTable tb;
117 tb = tk.setTable();
118 //string TinhTrang = "";
119 ado.ketNoi();
120 string query = "";
121 if (TextBox3.Text != "")
122 {
123 query = "Select Anh, TenSP,Gia,soluong,'chitiet.aspx?tensp='+tensp as chitiet from tblSanPham where TenSP like '" + TextBox3.Text + "%'";
124 }
125 ado.rd = ado.getData(query);
126 while (ado.rd.Read())
127 {
128 tb = tk.dienVaoBang(tb, ado.rd["Anh"].ToString(), ado.rd["TenSP"].ToString(), Convert.ToDouble(ado.rd["Gia"]), Convert.ToDouble(ado.rd["soluong"]), ado.rd["chitiet"].ToString());
129 //if ((bool)ado.rd.GetValue(3) == true)
130 // TinhTrang = "Còn Hàng";
131 //else
132 // TinhTrang = "Hết Hàng";
133
134 }
135 ado.dongKetNoi();
136 Session["KQTimKiem"] = tb;
137 Response.Redirect("timten.aspx", true);
138 }
139 catch (Exception ex)
140 {
141 Response.Write(ex.ToString());
142 }
143 }
144 }
145 protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
146 {
147
148 }
149 protected void Menu1_MenuItemClick1(object sender, MenuEventArgs e)
150 {
151
152 }
153 protected void DataList1_SelectedIndexChanged(object sender, EventArgs e)
154 {
155
156 }
157 }